﻿using System;
using UnityEngine;

namespace UnityStandardAssets.CinematicEffects
{
	// Token: 0x020005AD RID: 1453
	[RequireComponent(typeof(Camera))]
	[ExecuteInEditMode]
	[AddComponentMenu("Image Effects/Cinematic/Tonemapping and Color Grading")]
	public class TonemappingColorGrading : MonoBehaviour
	{
		// Token: 0x06001D04 RID: 7428 RVA: 0x000641A8 File Offset: 0x000623A8
		public TonemappingColorGrading()
		{
			this.m_EyeAdaptation = TonemappingColorGrading.EyeAdaptationSettings.defaultSettings;
			this.m_Tonemapping = TonemappingColorGrading.TonemappingSettings.defaultSettings;
			this.m_ColorGrading = TonemappingColorGrading.ColorGradingSettings.defaultSettings;
			this.m_Lut = TonemappingColorGrading.LUTSettings.defaultSettings;
			this.m_Dirty = true;
			this.m_TonemapperDirty = true;
		}

		// Token: 0x06001D05 RID: 7429 RVA: 0x000123D1 File Offset: 0x000105D1
		public void SetDirty()
		{
			this.m_Dirty = true;
		}

		// Token: 0x06001D06 RID: 7430 RVA: 0x000123DA File Offset: 0x000105DA
		public void OnValidate()
		{
			this.SetDirty();
			this.SetTonemapperDirty();
		}

		// Token: 0x06001D07 RID: 7431 RVA: 0x000641F8 File Offset: 0x000623F8
		public void Enable()
		{
			if (!ImageEffectHelper.IsSupported(this.shader, false, true, this))
			{
				base.enabled = false;
				return;
			}
			this.SetDirty();
			this.SetTonemapperDirty();
			Debug.Log("Tonemapping enabled!");
			this.m_Tonemapping = TonemappingColorGrading.TonemappingSettings.MyTonemappingSettings;
			this.m_Lut = TonemappingColorGrading.LUTSettings.MyLUTSettings;
			this.m_ColorGrading.basics = TonemappingColorGrading.BasicsSettings.MyBasicsSettings;
		}

		// Token: 0x06001D08 RID: 7432 RVA: 0x0006425C File Offset: 0x0006245C
		public static Color NormalizeColor(Color c)
		{
			float num = (c.r + c.g + c.b) / 3f;
			if (Mathf.Approximately(num, 0f))
			{
				return new Color(1f, 1f, 1f, 1f);
			}
			return new Color
			{
				r = c.r / num,
				g = c.g / num,
				b = c.b / num,
				a = 1f
			};
		}

		// Token: 0x06001D09 RID: 7433 RVA: 0x000642F0 File Offset: 0x000624F0
		public void OnDisable()
		{
			if (this.m_Material != null)
			{
				UnityEngine.Object.DestroyImmediate(this.m_Material);
			}
			if (this.m_IdentityLut != null)
			{
				UnityEngine.Object.DestroyImmediate(this.m_IdentityLut);
			}
			if (this.m_InternalLut != null)
			{
				UnityEngine.Object.DestroyImmediate(this.internalLutRt);
			}
			if (this.m_SmallAdaptiveRt != null)
			{
				UnityEngine.Object.DestroyImmediate(this.m_SmallAdaptiveRt);
			}
			if (this.m_CurveTexture != null)
			{
				UnityEngine.Object.DestroyImmediate(this.m_CurveTexture);
			}
			if (this.m_TonemapperCurve != null)
			{
				UnityEngine.Object.DestroyImmediate(this.m_TonemapperCurve);
			}
			this.m_Material = null;
			this.m_IdentityLut = null;
			this.m_InternalLut = null;
			this.m_SmallAdaptiveRt = null;
			this.m_CurveTexture = null;
			this.m_TonemapperCurve = null;
		}

		// Token: 0x06001D0A RID: 7434 RVA: 0x000643C0 File Offset: 0x000625C0
		[ImageEffectTransformsToLDR]
		public void Render(RenderTexture source, RenderTexture destination)
		{
			this.material.shaderKeywords = null;
			RenderTexture renderTexture = null;
			RenderTexture[] array = null;
			if (this.eyeAdaptation.enabled)
			{
				bool flag = this.CheckSmallAdaptiveRt();
				int num = (source.width >= source.height) ? source.height : source.width;
				int num2 = num | num >> 1;
				int num3 = num2 | num2 >> 2;
				int num4 = num3 | num3 >> 4;
				int num5 = num4 | num4 >> 8;
				int num6 = num5 | num5 >> 16;
				int num7 = num6 - (num6 >> 1);
				renderTexture = RenderTexture.GetTemporary(num7, num7, 0, this.m_AdaptiveRtFormat);
				Graphics.Blit(source, renderTexture);
				int num8 = (int)Mathf.Log((float)renderTexture.width, 2f);
				int num9 = 2;
				array = new RenderTexture[num8];
				for (int i = 0; i < num8; i++)
				{
					array[i] = RenderTexture.GetTemporary(renderTexture.width / num9, renderTexture.width / num9, 0, this.m_AdaptiveRtFormat);
					num9 <<= 1;
				}
				RenderTexture source2 = array[num8 - 1];
				Graphics.Blit(renderTexture, array[0], this.material, 1);
				for (int j = 0; j < num8 - 1; j++)
				{
					Graphics.Blit(array[j], array[j + 1]);
					source2 = array[j + 1];
				}
				this.m_SmallAdaptiveRt.MarkRestoreExpected();
				this.material.SetFloat("_AdaptationSpeed", Mathf.Max(this.eyeAdaptation.speed, 0.001f));
				Graphics.Blit(source2, this.m_SmallAdaptiveRt, this.material, (!flag) ? 2 : 3);
				this.material.SetFloat("_MiddleGrey", this.eyeAdaptation.middleGrey);
				this.material.SetFloat("_AdaptationMin", Mathf.Pow(2f, this.eyeAdaptation.min));
				this.material.SetFloat("_AdaptationMax", Mathf.Pow(2f, this.eyeAdaptation.max));
				this.material.SetTexture("_LumTex", this.m_SmallAdaptiveRt);
				this.material.EnableKeyword("ENABLE_EYE_ADAPTATION");
			}
			int num10 = 4;
			if (this.tonemapping.enabled)
			{
				if (this.tonemapping.tonemapper == TonemappingColorGrading.Tonemapper.Curve)
				{
					if (this.m_TonemapperDirty)
					{
						float num11 = 1f;
						if (this.tonemapping.curve.length > 0)
						{
							num11 = this.tonemapping.curve[this.tonemapping.curve.length - 1].time;
							for (float num12 = 0f; num12 <= 1f; num12 += 0.003921569f)
							{
								float num13 = this.tonemapping.curve.Evaluate(num12 * num11);
								this.tonemapperCurve.SetPixel(Mathf.FloorToInt(num12 * 255f), 0, new Color(num13, num13, num13));
							}
							this.tonemapperCurve.Apply();
						}
						this.m_TonemapperCurveRange = 1f / num11;
						this.m_TonemapperDirty = false;
					}
					this.material.SetFloat("_ToneCurveRange", this.m_TonemapperCurveRange);
					this.material.SetTexture("_ToneCurve", this.tonemapperCurve);
				}
				else if (this.tonemapping.tonemapper == TonemappingColorGrading.Tonemapper.Neutral)
				{
					float num14 = this.tonemapping.neutralBlackIn * 20f + 1f;
					float num15 = this.tonemapping.neutralBlackOut * 10f + 1f;
					float num16 = this.tonemapping.neutralWhiteIn / 20f;
					float num17 = 1f - this.tonemapping.neutralWhiteOut / 20f;
					float t = num14 / num15;
					float t2 = num16 / num17;
					float y = Mathf.Max(0f, Mathf.LerpUnclamped(0.57f, 0.37f, t));
					float z = Mathf.LerpUnclamped(0.01f, 0.24f, t2);
					float w = Mathf.Max(0f, Mathf.LerpUnclamped(0.02f, 0.2f, t));
					this.material.SetVector("_NeutralTonemapperParams1", new Vector4(0.2f, y, z, w));
					this.material.SetVector("_NeutralTonemapperParams2", new Vector4(0.02f, 0.3f, this.tonemapping.neutralWhiteLevel, this.tonemapping.neutralWhiteClip / 10f));
				}
				this.material.SetFloat("_Exposure", this.tonemapping.exposure);
				num10 = (int)(num10 + (this.tonemapping.tonemapper + 1));
			}
			if (this.colorGrading.enabled)
			{
				if (this.m_Dirty || !this.m_InternalLut.IsCreated())
				{
					Color c;
					Color c2;
					Color c3;
					this.GenerateLiftGammaGain(out c, out c2, out c3);
					this.GenCurveTexture();
					this.material.SetVector("_WhiteBalance", this.GetWhiteBalance());
					this.material.SetVector("_Lift", c);
					this.material.SetVector("_Gamma", c2);
					this.material.SetVector("_Gain", c3);
					this.material.SetVector("_ContrastGainGamma", new Vector3(this.colorGrading.basics.contrast, this.colorGrading.basics.gain, 1f / this.colorGrading.basics.gamma));
					this.material.SetFloat("_Vibrance", this.colorGrading.basics.vibrance);
					this.material.SetVector("_HSV", new Vector4(this.colorGrading.basics.hue, this.colorGrading.basics.saturation, this.colorGrading.basics.value));
					this.material.SetVector("_ChannelMixerRed", this.colorGrading.channelMixer.channels[0]);
					this.material.SetVector("_ChannelMixerGreen", this.colorGrading.channelMixer.channels[1]);
					this.material.SetVector("_ChannelMixerBlue", this.colorGrading.channelMixer.channels[2]);
					this.material.SetTexture("_CurveTex", this.curveTexture);
					this.internalLutRt.MarkRestoreExpected();
					Graphics.Blit(this.identityLut, this.internalLutRt, this.material, 0);
					this.m_Dirty = false;
				}
				this.material.EnableKeyword("ENABLE_COLOR_GRADING");
				if (this.colorGrading.useDithering)
				{
					this.material.EnableKeyword("ENABLE_DITHERING");
				}
				this.material.SetTexture("_InternalLutTex", this.internalLutRt);
				this.material.SetVector("_InternalLutParams", new Vector3(1f / (float)this.internalLutRt.width, 1f / (float)this.internalLutRt.height, (float)this.internalLutRt.height - 1f));
			}
			if (this.lut.enabled && this.lut.texture != null && this.CheckUserLut())
			{
				this.material.SetTexture("_UserLutTex", this.lut.texture);
				this.material.SetVector("_UserLutParams", new Vector4(1f / (float)this.lut.texture.width, 1f / (float)this.lut.texture.height, (float)this.lut.texture.height - 1f, this.lut.contribution));
				this.material.EnableKeyword("ENABLE_USER_LUT");
			}
			Graphics.Blit(source, destination, this.material, num10);
			if (this.eyeAdaptation.enabled)
			{
				for (int k = 0; k < array.Length; k++)
				{
					RenderTexture.ReleaseTemporary(array[k]);
				}
				RenderTexture.ReleaseTemporary(renderTexture);
			}
		}

		// Token: 0x06001D0B RID: 7435 RVA: 0x000123E8 File Offset: 0x000105E8
		public void SetTonemapperDirty()
		{
			this.m_TonemapperDirty = true;
		}

		// Token: 0x06001D0C RID: 7436 RVA: 0x00064BBC File Offset: 0x00062DBC
		public static Texture2D GenerateIdentityLut(int dim)
		{
			Color[] array = new Color[dim * dim * dim];
			float num = 1f / ((float)dim - 1f);
			for (int i = 0; i < dim; i++)
			{
				for (int j = 0; j < dim; j++)
				{
					for (int k = 0; k < dim; k++)
					{
						array[i + j * dim + k * dim * dim] = new Color((float)i * num, Mathf.Abs((float)k * num), (float)j * num, 1f);
					}
				}
			}
			Texture2D texture2D = new Texture2D(dim * dim, dim, TextureFormat.RGB24, false, true);
			texture2D.name = "Identity LUT";
			texture2D.filterMode = FilterMode.Bilinear;
			texture2D.anisoLevel = 0;
			texture2D.hideFlags = HideFlags.DontSave;
			texture2D.SetPixels(array);
			texture2D.Apply();
			return texture2D;
		}

		// Token: 0x06001D0D RID: 7437 RVA: 0x000123F1 File Offset: 0x000105F1
		public float StandardIlluminantY(float x)
		{
			return 2.87f * x - 3f * x * x - 0.275095075f;
		}

		// Token: 0x06001D0E RID: 7438 RVA: 0x00064C74 File Offset: 0x00062E74
		public Vector3 CIExyToLMS(float x, float y)
		{
			float num = 1f;
			float num2 = num * x / y;
			float num3 = num * (1f - x - y) / y;
			float x2 = 0.7328f * num2 + 0.4296f * num - 0.1624f * num3;
			float y2 = -0.7036f * num2 + 1.6975f * num + 0.0061f * num3;
			float z = 0.003f * num2 + 0.0136f * num + 0.9834f * num3;
			return new Vector3(x2, y2, z);
		}

		// Token: 0x06001D0F RID: 7439 RVA: 0x00064CEC File Offset: 0x00062EEC
		public Vector3 GetWhiteBalance()
		{
			float temperatureShift = this.colorGrading.basics.temperatureShift;
			float tint = this.colorGrading.basics.tint;
			float x = 0.31271f - temperatureShift * ((temperatureShift >= 0f) ? 0.05f : 0.1f);
			float y = this.StandardIlluminantY(x) + tint * 0.05f;
			Vector3 vector = new Vector3(0.949237f, 1.03542f, 1.08728f);
			Vector3 vector2 = this.CIExyToLMS(x, y);
			return new Vector3(vector.x / vector2.x, vector.y / vector2.y, vector.z / vector2.z);
		}

		// Token: 0x06001D10 RID: 7440 RVA: 0x00064D9C File Offset: 0x00062F9C
		public void GenerateLiftGammaGain(out Color lift, out Color gamma, out Color gain)
		{
			Color color = TonemappingColorGrading.NormalizeColor(this.colorGrading.colorWheels.shadows);
			Color color2 = TonemappingColorGrading.NormalizeColor(this.colorGrading.colorWheels.midtones);
			Color color3 = TonemappingColorGrading.NormalizeColor(this.colorGrading.colorWheels.highlights);
			float num = (color.r + color.g + color.b) / 3f;
			float num2 = (color2.r + color2.g + color2.b) / 3f;
			float num3 = (color3.r + color3.g + color3.b) / 3f;
			float r = (color.r - num) * 0.1f;
			float g = (color.g - num) * 0.1f;
			float b = (color.b - num) * 0.1f;
			float b2 = Mathf.Pow(2f, (color2.r - num2) * 0.5f);
			float b3 = Mathf.Pow(2f, (color2.g - num2) * 0.5f);
			float b4 = Mathf.Pow(2f, (color2.b - num2) * 0.5f);
			float r2 = Mathf.Pow(2f, (color3.r - num3) * 0.5f);
			float g2 = Mathf.Pow(2f, (color3.g - num3) * 0.5f);
			float b5 = Mathf.Pow(2f, (color3.b - num3) * 0.5f);
			float r3 = 1f / Mathf.Max(0.01f, b2);
			float g3 = 1f / Mathf.Max(0.01f, b3);
			float b6 = 1f / Mathf.Max(0.01f, b4);
			lift = new Color(r, g, b);
			gamma = new Color(r3, g3, b6);
			gain = new Color(r2, g2, b5);
		}

		// Token: 0x06001D11 RID: 7441 RVA: 0x00064F80 File Offset: 0x00063180
		public void GenCurveTexture()
		{
			AnimationCurve master = this.colorGrading.curves.master;
			AnimationCurve red = this.colorGrading.curves.red;
			AnimationCurve green = this.colorGrading.curves.green;
			AnimationCurve blue = this.colorGrading.curves.blue;
			Color[] array = new Color[256];
			for (float num = 0f; num <= 1f; num += 0.003921569f)
			{
				float a = Mathf.Clamp(master.Evaluate(num), 0f, 1f);
				float r = Mathf.Clamp(red.Evaluate(num), 0f, 1f);
				float g = Mathf.Clamp(green.Evaluate(num), 0f, 1f);
				float b = Mathf.Clamp(blue.Evaluate(num), 0f, 1f);
				array[(int)Mathf.Floor(num * 255f)] = new Color(r, g, b, a);
			}
			this.curveTexture.SetPixels(array);
			this.curveTexture.Apply();
		}

		// Token: 0x06001D12 RID: 7442 RVA: 0x0001240A File Offset: 0x0001060A
		public bool CheckUserLut()
		{
			this.validUserLutSize = (this.lut.texture.height == (int)Mathf.Sqrt((float)this.lut.texture.width));
			return this.validUserLutSize;
		}

		// Token: 0x06001D13 RID: 7443 RVA: 0x000650A0 File Offset: 0x000632A0
		public bool CheckSmallAdaptiveRt()
		{
			if (this.m_SmallAdaptiveRt != null)
			{
				return false;
			}
			this.m_AdaptiveRtFormat = RenderTextureFormat.ARGBHalf;
			if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RGHalf))
			{
				this.m_AdaptiveRtFormat = RenderTextureFormat.RGHalf;
			}
			this.m_SmallAdaptiveRt = new RenderTexture(1, 1, 0, this.m_AdaptiveRtFormat);
			this.m_SmallAdaptiveRt.hideFlags = HideFlags.DontSave;
			return true;
		}

		// Token: 0x06001D14 RID: 7444 RVA: 0x000650F8 File Offset: 0x000632F8
		public void OnGUI()
		{
			if (Event.current.type != EventType.Repaint)
			{
				return;
			}
			int num = 0;
			if (this.m_InternalLut != null && this.colorGrading.enabled && this.colorGrading.showDebug)
			{
				Graphics.DrawTexture(new Rect(0f, (float)num, (float)(this.lutSize * this.lutSize), (float)this.lutSize), this.internalLutRt);
				num += this.lutSize;
			}
			if (this.m_SmallAdaptiveRt != null && this.eyeAdaptation.enabled && this.eyeAdaptation.showDebug)
			{
				this.m_Material.SetPass(12);
				Graphics.DrawTexture(new Rect(0f, (float)num, 256f, 16f), this.m_SmallAdaptiveRt, this.m_Material);
			}
		}

		// Token: 0x06001D15 RID: 7445 RVA: 0x000651D0 File Offset: 0x000633D0
		public Texture2D BakeLUT()
		{
			Texture2D texture2D = new Texture2D(this.internalLutRt.width, this.internalLutRt.height, TextureFormat.RGB24, false, true);
			RenderTexture.active = this.internalLutRt;
			texture2D.ReadPixels(new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), 0, 0);
			RenderTexture.active = null;
			return texture2D;
		}

		// Token: 0x17000214 RID: 532
		// (get) Token: 0x06001D16 RID: 7446 RVA: 0x00012441 File Offset: 0x00010641
		// (set) Token: 0x06001D17 RID: 7447 RVA: 0x00012449 File Offset: 0x00010649
		public TonemappingColorGrading.EyeAdaptationSettings eyeAdaptation
		{
			get
			{
				return this.m_EyeAdaptation;
			}
			set
			{
				this.m_EyeAdaptation = value;
			}
		}

		// Token: 0x17000215 RID: 533
		// (get) Token: 0x06001D18 RID: 7448 RVA: 0x00012452 File Offset: 0x00010652
		// (set) Token: 0x06001D19 RID: 7449 RVA: 0x0001245A File Offset: 0x0001065A
		public TonemappingColorGrading.TonemappingSettings tonemapping
		{
			get
			{
				return this.m_Tonemapping;
			}
			set
			{
				this.m_Tonemapping = value;
				this.SetTonemapperDirty();
			}
		}

		// Token: 0x17000216 RID: 534
		// (get) Token: 0x06001D1A RID: 7450 RVA: 0x00012469 File Offset: 0x00010669
		// (set) Token: 0x06001D1B RID: 7451 RVA: 0x00012471 File Offset: 0x00010671
		public TonemappingColorGrading.ColorGradingSettings colorGrading
		{
			get
			{
				return this.m_ColorGrading;
			}
			set
			{
				this.m_ColorGrading = value;
				this.SetDirty();
			}
		}

		// Token: 0x17000217 RID: 535
		// (get) Token: 0x06001D1C RID: 7452 RVA: 0x00012480 File Offset: 0x00010680
		// (set) Token: 0x06001D1D RID: 7453 RVA: 0x00012488 File Offset: 0x00010688
		public TonemappingColorGrading.LUTSettings lut
		{
			get
			{
				return this.m_Lut;
			}
			set
			{
				this.m_Lut = value;
			}
		}

		// Token: 0x17000218 RID: 536
		// (get) Token: 0x06001D1E RID: 7454 RVA: 0x00065234 File Offset: 0x00063434
		public Texture2D identityLut
		{
			get
			{
				if (this.m_IdentityLut == null || this.m_IdentityLut.height != this.lutSize)
				{
					UnityEngine.Object.DestroyImmediate(this.m_IdentityLut);
					this.m_IdentityLut = TonemappingColorGrading.GenerateIdentityLut(this.lutSize);
				}
				return this.m_IdentityLut;
			}
		}

		// Token: 0x17000219 RID: 537
		// (get) Token: 0x06001D1F RID: 7455 RVA: 0x00065284 File Offset: 0x00063484
		public RenderTexture internalLutRt
		{
			get
			{
				if (this.m_InternalLut == null || !this.m_InternalLut.IsCreated() || this.m_InternalLut.height != this.lutSize)
				{
					UnityEngine.Object.DestroyImmediate(this.m_InternalLut);
					this.m_InternalLut = new RenderTexture(this.lutSize * this.lutSize, this.lutSize, 0, RenderTextureFormat.ARGB32)
					{
						name = "Internal LUT",
						filterMode = FilterMode.Bilinear,
						anisoLevel = 0,
						hideFlags = HideFlags.DontSave
					};
				}
				return this.m_InternalLut;
			}
		}

		// Token: 0x1700021A RID: 538
		// (get) Token: 0x06001D20 RID: 7456 RVA: 0x00065314 File Offset: 0x00063514
		public Texture2D curveTexture
		{
			get
			{
				if (this.m_CurveTexture == null)
				{
					this.m_CurveTexture = new Texture2D(256, 1, TextureFormat.ARGB32, false, true)
					{
						name = "Curve texture",
						wrapMode = TextureWrapMode.Clamp,
						filterMode = FilterMode.Bilinear,
						anisoLevel = 0,
						hideFlags = HideFlags.DontSave
					};
				}
				return this.m_CurveTexture;
			}
		}

		// Token: 0x1700021B RID: 539
		// (get) Token: 0x06001D21 RID: 7457 RVA: 0x00065374 File Offset: 0x00063574
		public Texture2D tonemapperCurve
		{
			get
			{
				if (this.m_TonemapperCurve == null)
				{
					TextureFormat format = TextureFormat.RGB24;
					if (SystemInfo.SupportsTextureFormat(TextureFormat.RFloat))
					{
						format = TextureFormat.RFloat;
					}
					else if (SystemInfo.SupportsTextureFormat(TextureFormat.RHalf))
					{
						format = TextureFormat.RHalf;
					}
					this.m_TonemapperCurve = new Texture2D(256, 1, format, false, true)
					{
						name = "Tonemapper curve texture",
						wrapMode = TextureWrapMode.Clamp,
						filterMode = FilterMode.Bilinear,
						anisoLevel = 0,
						hideFlags = HideFlags.DontSave
					};
				}
				return this.m_TonemapperCurve;
			}
		}

		// Token: 0x1700021C RID: 540
		// (get) Token: 0x06001D22 RID: 7458 RVA: 0x00012491 File Offset: 0x00010691
		public Shader shader
		{
			get
			{
				if (this.m_Shader == null)
				{
					this.m_Shader = TonemappingColorGrading.ToneMappingShader;
				}
				return this.m_Shader;
			}
		}

		// Token: 0x1700021D RID: 541
		// (get) Token: 0x06001D23 RID: 7459 RVA: 0x000124B2 File Offset: 0x000106B2
		public Material material
		{
			get
			{
				if (this.m_Material == null)
				{
					this.m_Material = ImageEffectHelper.CheckShaderAndCreateMaterial(this.shader);
				}
				return this.m_Material;
			}
		}

		// Token: 0x1700021E RID: 542
		// (get) Token: 0x06001D24 RID: 7460 RVA: 0x000124D9 File Offset: 0x000106D9
		public bool isGammaColorSpace
		{
			get
			{
				return QualitySettings.activeColorSpace == ColorSpace.Gamma;
			}
		}

		// Token: 0x1700021F RID: 543
		// (get) Token: 0x06001D25 RID: 7461 RVA: 0x000124E3 File Offset: 0x000106E3
		public int lutSize
		{
			get
			{
				return (int)this.colorGrading.precision;
			}
		}

		// Token: 0x17000220 RID: 544
		// (get) Token: 0x06001D26 RID: 7462 RVA: 0x000124F0 File Offset: 0x000106F0
		// (set) Token: 0x06001D27 RID: 7463 RVA: 0x000124F8 File Offset: 0x000106F8
		public bool validRenderTextureFormat { get; set; }

		// Token: 0x17000221 RID: 545
		// (get) Token: 0x06001D28 RID: 7464 RVA: 0x00012501 File Offset: 0x00010701
		// (set) Token: 0x06001D29 RID: 7465 RVA: 0x00012509 File Offset: 0x00010709
		public bool validUserLutSize { get; set; }

		// Token: 0x040015C2 RID: 5570
		public bool m_Dirty;

		// Token: 0x040015C5 RID: 5573
		[SerializeField]
		[TonemappingColorGrading.SettingsGroup]
		public TonemappingColorGrading.EyeAdaptationSettings m_EyeAdaptation;

		// Token: 0x040015C6 RID: 5574
		[SerializeField]
		[TonemappingColorGrading.SettingsGroup]
		public TonemappingColorGrading.TonemappingSettings m_Tonemapping;

		// Token: 0x040015C7 RID: 5575
		[SerializeField]
		[TonemappingColorGrading.SettingsGroup]
		public TonemappingColorGrading.ColorGradingSettings m_ColorGrading;

		// Token: 0x040015C8 RID: 5576
		[SerializeField]
		[TonemappingColorGrading.SettingsGroup]
		public TonemappingColorGrading.LUTSettings m_Lut;

		// Token: 0x040015C9 RID: 5577
		public Texture2D m_IdentityLut;

		// Token: 0x040015CA RID: 5578
		public RenderTexture m_InternalLut;

		// Token: 0x040015CB RID: 5579
		public Texture2D m_CurveTexture;

		// Token: 0x040015CC RID: 5580
		public Texture2D m_TonemapperCurve;

		// Token: 0x040015CD RID: 5581
		public float m_TonemapperCurveRange;

		// Token: 0x040015CE RID: 5582
		[SerializeField]
		public Shader m_Shader;

		// Token: 0x040015CF RID: 5583
		public Material m_Material;

		// Token: 0x040015D0 RID: 5584
		public bool m_TonemapperDirty;

		// Token: 0x040015D1 RID: 5585
		public RenderTexture m_SmallAdaptiveRt;

		// Token: 0x040015D2 RID: 5586
		public RenderTextureFormat m_AdaptiveRtFormat;

		// Token: 0x040015D3 RID: 5587
		public static Shader ToneMappingShader;

		// Token: 0x020005AE RID: 1454
		[AttributeUsage(AttributeTargets.Field)]
		public class SettingsGroup : Attribute
		{
		}

		// Token: 0x020005AF RID: 1455
		public class ColorWheelGroup : PropertyAttribute
		{
			// Token: 0x06001D2B RID: 7467 RVA: 0x0001251A File Offset: 0x0001071A
			public ColorWheelGroup()
			{
			}

			// Token: 0x06001D2C RID: 7468 RVA: 0x00012535 File Offset: 0x00010735
			public ColorWheelGroup(int minSizePerWheel, int maxSizePerWheel)
			{
				this.minSizePerWheel = minSizePerWheel;
				this.maxSizePerWheel = maxSizePerWheel;
			}

			// Token: 0x040015D4 RID: 5588
			public int minSizePerWheel = 60;

			// Token: 0x040015D5 RID: 5589
			public int maxSizePerWheel = 150;
		}

		// Token: 0x020005B0 RID: 1456
		public class IndentedGroup : PropertyAttribute
		{
		}

		// Token: 0x020005B1 RID: 1457
		public class ChannelMixer : PropertyAttribute
		{
		}

		// Token: 0x020005B2 RID: 1458
		public class Curve : PropertyAttribute
		{
			// Token: 0x06001D2F RID: 7471 RVA: 0x0001255E File Offset: 0x0001075E
			public Curve()
			{
			}

			// Token: 0x06001D30 RID: 7472 RVA: 0x00012571 File Offset: 0x00010771
			public Curve(float r, float g, float b, float a)
			{
				this.color = new Color(r, g, b, a);
			}

			// Token: 0x040015D6 RID: 5590
			public Color color = Color.white;
		}

		// Token: 0x020005B3 RID: 1459
		[Serializable]
		public struct EyeAdaptationSettings
		{
			// Token: 0x17000222 RID: 546
			// (get) Token: 0x06001D31 RID: 7473 RVA: 0x000653F0 File Offset: 0x000635F0
			public static TonemappingColorGrading.EyeAdaptationSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.EyeAdaptationSettings
					{
						enabled = false,
						showDebug = false,
						middleGrey = 0.5f,
						min = -3f,
						max = 3f,
						speed = 1.5f
					};
				}
			}

			// Token: 0x040015D7 RID: 5591
			public bool enabled;

			// Token: 0x040015D8 RID: 5592
			[Tooltip("Midpoint Adjustment.")]
			[Min(0f)]
			public float middleGrey;

			// Token: 0x040015D9 RID: 5593
			[Tooltip("The lowest possible exposure value; adjust this value to modify the brightest areas of your level.")]
			public float min;

			// Token: 0x040015DA RID: 5594
			[Tooltip("The highest possible exposure value; adjust this value to modify the darkest areas of your level.")]
			public float max;

			// Token: 0x040015DB RID: 5595
			[Tooltip("Speed of linear adaptation. Higher is faster.")]
			[Min(0f)]
			public float speed;

			// Token: 0x040015DC RID: 5596
			[Tooltip("Displays a luminosity helper in the GameView.")]
			public bool showDebug;
		}

		// Token: 0x020005B4 RID: 1460
		public enum Tonemapper
		{
			// Token: 0x040015DE RID: 5598
			ACES,
			// Token: 0x040015DF RID: 5599
			Curve,
			// Token: 0x040015E0 RID: 5600
			Hable,
			// Token: 0x040015E1 RID: 5601
			HejlDawson,
			// Token: 0x040015E2 RID: 5602
			Photographic,
			// Token: 0x040015E3 RID: 5603
			Reinhard,
			// Token: 0x040015E4 RID: 5604
			Neutral
		}

		// Token: 0x020005B5 RID: 1461
		[Serializable]
		public struct TonemappingSettings
		{
			// Token: 0x17000223 RID: 547
			// (get) Token: 0x06001D32 RID: 7474 RVA: 0x00065448 File Offset: 0x00063648
			public static TonemappingColorGrading.TonemappingSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.TonemappingSettings
					{
						enabled = true,
						tonemapper = TonemappingColorGrading.Tonemapper.ACES,
						exposure = 1f,
						curve = TonemappingColorGrading.CurvesSettings.defaultCurve,
						neutralBlackIn = 0.02f,
						neutralWhiteIn = 10f,
						neutralBlackOut = 0f,
						neutralWhiteOut = 10f,
						neutralWhiteLevel = 5.3f,
						neutralWhiteClip = 10f
					};
				}
			}

			// Token: 0x040015E5 RID: 5605
			public bool enabled;

			// Token: 0x040015E6 RID: 5606
			[Tooltip("Tonemapping technique to use. ACES is the recommended one.")]
			public TonemappingColorGrading.Tonemapper tonemapper;

			// Token: 0x040015E7 RID: 5607
			[Min(0f)]
			[Tooltip("Adjusts the overall exposure of the scene.")]
			public float exposure;

			// Token: 0x040015E8 RID: 5608
			[Tooltip("Custom tonemapping curve.")]
			public AnimationCurve curve;

			// Token: 0x040015E9 RID: 5609
			[Range(-0.1f, 0.1f)]
			public float neutralBlackIn;

			// Token: 0x040015EA RID: 5610
			[Range(1f, 20f)]
			public float neutralWhiteIn;

			// Token: 0x040015EB RID: 5611
			[Range(-0.09f, 0.1f)]
			public float neutralBlackOut;

			// Token: 0x040015EC RID: 5612
			[Range(1f, 19f)]
			public float neutralWhiteOut;

			// Token: 0x040015ED RID: 5613
			[Range(0.1f, 20f)]
			public float neutralWhiteLevel;

			// Token: 0x040015EE RID: 5614
			[Range(1f, 10f)]
			public float neutralWhiteClip;

			// Token: 0x040015EF RID: 5615
			public static TonemappingColorGrading.TonemappingSettings MyTonemappingSettings;
		}

		// Token: 0x020005B6 RID: 1462
		[Serializable]
		public struct LUTSettings
		{
			// Token: 0x17000224 RID: 548
			// (get) Token: 0x06001D33 RID: 7475 RVA: 0x000654D0 File Offset: 0x000636D0
			public static TonemappingColorGrading.LUTSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.LUTSettings
					{
						enabled = false,
						texture = null,
						contribution = 1f
					};
				}
			}

			// Token: 0x040015F0 RID: 5616
			public bool enabled;

			// Token: 0x040015F1 RID: 5617
			[Tooltip("Custom lookup texture (strip format, e.g. 256x16).")]
			public Texture texture;

			// Token: 0x040015F2 RID: 5618
			[Tooltip("Blending factor.")]
			[Range(0f, 1f)]
			public float contribution;

			// Token: 0x040015F3 RID: 5619
			public static TonemappingColorGrading.LUTSettings MyLUTSettings;
		}

		// Token: 0x020005B7 RID: 1463
		[Serializable]
		public struct ColorWheelsSettings
		{
			// Token: 0x17000225 RID: 549
			// (get) Token: 0x06001D34 RID: 7476 RVA: 0x00065504 File Offset: 0x00063704
			public static TonemappingColorGrading.ColorWheelsSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.ColorWheelsSettings
					{
						shadows = Color.white,
						midtones = Color.white,
						highlights = Color.white
					};
				}
			}

			// Token: 0x040015F4 RID: 5620
			[ColorUsage(false)]
			public Color shadows;

			// Token: 0x040015F5 RID: 5621
			[ColorUsage(false)]
			public Color midtones;

			// Token: 0x040015F6 RID: 5622
			[ColorUsage(false)]
			public Color highlights;
		}

		// Token: 0x020005B8 RID: 1464
		[Serializable]
		public struct BasicsSettings
		{
			// Token: 0x17000226 RID: 550
			// (get) Token: 0x06001D35 RID: 7477 RVA: 0x00065540 File Offset: 0x00063740
			public static TonemappingColorGrading.BasicsSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.BasicsSettings
					{
						temperatureShift = 0f,
						tint = 0f,
						contrast = 1f,
						hue = 0f,
						saturation = 1f,
						value = 1f,
						vibrance = 0f,
						gain = 1f,
						gamma = 1f
					};
				}
			}

			// Token: 0x040015F7 RID: 5623
			[Range(-2f, 2f)]
			[Tooltip("Sets the white balance to a custom color temperature.")]
			public float temperatureShift;

			// Token: 0x040015F8 RID: 5624
			[Tooltip("Sets the white balance to compensate for a green or magenta tint.")]
			[Range(-2f, 2f)]
			public float tint;

			// Token: 0x040015F9 RID: 5625
			[Space]
			[Range(-0.5f, 0.5f)]
			[Tooltip("Shift the hue of all colors.")]
			public float hue;

			// Token: 0x040015FA RID: 5626
			[Range(0f, 2f)]
			[Tooltip("Pushes the intensity of all colors.")]
			public float saturation;

			// Token: 0x040015FB RID: 5627
			[Tooltip("Adjusts the saturation so that clipping is minimized as colors approach full saturation.")]
			[Range(-1f, 1f)]
			public float vibrance;

			// Token: 0x040015FC RID: 5628
			[Tooltip("Brightens or darkens all colors.")]
			[Range(0f, 10f)]
			public float value;

			// Token: 0x040015FD RID: 5629
			[Tooltip("Expands or shrinks the overall range of tonal values.")]
			[Space]
			[Range(0f, 2f)]
			public float contrast;

			// Token: 0x040015FE RID: 5630
			[Tooltip("Contrast gain curve. Controls the steepness of the curve.")]
			[Range(0.01f, 5f)]
			public float gain;

			// Token: 0x040015FF RID: 5631
			[Tooltip("Applies a pow function to the source.")]
			[Range(0.01f, 5f)]
			public float gamma;

			// Token: 0x04001600 RID: 5632
			public static TonemappingColorGrading.BasicsSettings MyBasicsSettings;
		}

		// Token: 0x020005B9 RID: 1465
		[Serializable]
		public struct ChannelMixerSettings
		{
			// Token: 0x17000227 RID: 551
			// (get) Token: 0x06001D36 RID: 7478 RVA: 0x000655C4 File Offset: 0x000637C4
			public static TonemappingColorGrading.ChannelMixerSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.ChannelMixerSettings
					{
						currentChannel = 0,
						channels = new Vector3[]
						{
							new Vector3(1f, 0f, 0f),
							new Vector3(0f, 1f, 0f),
							new Vector3(0f, 0f, 1f)
						}
					};
				}
			}

			// Token: 0x04001601 RID: 5633
			public int currentChannel;

			// Token: 0x04001602 RID: 5634
			public Vector3[] channels;
		}

		// Token: 0x020005BA RID: 1466
		[Serializable]
		public struct CurvesSettings
		{
			// Token: 0x17000228 RID: 552
			// (get) Token: 0x06001D37 RID: 7479 RVA: 0x00065640 File Offset: 0x00063840
			public static TonemappingColorGrading.CurvesSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.CurvesSettings
					{
						master = TonemappingColorGrading.CurvesSettings.defaultCurve,
						red = TonemappingColorGrading.CurvesSettings.defaultCurve,
						green = TonemappingColorGrading.CurvesSettings.defaultCurve,
						blue = TonemappingColorGrading.CurvesSettings.defaultCurve
					};
				}
			}

			// Token: 0x17000229 RID: 553
			// (get) Token: 0x06001D38 RID: 7480 RVA: 0x00065688 File Offset: 0x00063888
			public static AnimationCurve defaultCurve
			{
				get
				{
					return new AnimationCurve(new Keyframe[]
					{
						new Keyframe(0f, 0f, 1f, 1f),
						new Keyframe(1f, 1f, 1f, 1f)
					});
				}
			}

			// Token: 0x04001603 RID: 5635
			[TonemappingColorGrading.Curve]
			public AnimationCurve master;

			// Token: 0x04001604 RID: 5636
			[TonemappingColorGrading.Curve(1f, 0f, 0f, 1f)]
			public AnimationCurve red;

			// Token: 0x04001605 RID: 5637
			[TonemappingColorGrading.Curve(0f, 1f, 0f, 1f)]
			public AnimationCurve green;

			// Token: 0x04001606 RID: 5638
			[TonemappingColorGrading.Curve(0f, 1f, 1f, 1f)]
			public AnimationCurve blue;
		}

		// Token: 0x020005BB RID: 1467
		public enum ColorGradingPrecision
		{
			// Token: 0x04001608 RID: 5640
			Normal = 16,
			// Token: 0x04001609 RID: 5641
			High = 32
		}

		// Token: 0x020005BC RID: 1468
		[Serializable]
		public struct ColorGradingSettings
		{
			// Token: 0x1700022A RID: 554
			// (get) Token: 0x06001D39 RID: 7481 RVA: 0x000656E0 File Offset: 0x000638E0
			public static TonemappingColorGrading.ColorGradingSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.ColorGradingSettings
					{
						enabled = true,
						useDithering = true,
						showDebug = false,
						precision = TonemappingColorGrading.ColorGradingPrecision.High,
						colorWheels = TonemappingColorGrading.ColorWheelsSettings.defaultSettings,
						basics = TonemappingColorGrading.BasicsSettings.defaultSettings,
						channelMixer = TonemappingColorGrading.ChannelMixerSettings.defaultSettings,
						curves = TonemappingColorGrading.CurvesSettings.defaultSettings
					};
				}
			}

			// Token: 0x06001D3A RID: 7482 RVA: 0x00012594 File Offset: 0x00010794
			internal void Reset()
			{
				this.curves = TonemappingColorGrading.CurvesSettings.defaultSettings;
			}

			// Token: 0x0400160A RID: 5642
			public bool enabled;

			// Token: 0x0400160B RID: 5643
			[Tooltip("Internal LUT precision. \"Normal\" is 256x16, \"High\" is 1024x32. Prefer \"Normal\" on mobile devices.")]
			public TonemappingColorGrading.ColorGradingPrecision precision;

			// Token: 0x0400160C RID: 5644
			[TonemappingColorGrading.ColorWheelGroup]
			[Space]
			public TonemappingColorGrading.ColorWheelsSettings colorWheels;

			// Token: 0x0400160D RID: 5645
			[TonemappingColorGrading.IndentedGroup]
			[Space]
			public TonemappingColorGrading.BasicsSettings basics;

			// Token: 0x0400160E RID: 5646
			[Space]
			[TonemappingColorGrading.ChannelMixer]
			public TonemappingColorGrading.ChannelMixerSettings channelMixer;

			// Token: 0x0400160F RID: 5647
			[TonemappingColorGrading.IndentedGroup]
			[Space]
			public TonemappingColorGrading.CurvesSettings curves;

			// Token: 0x04001610 RID: 5648
			[Tooltip("Use dithering to try and minimize color banding in dark areas.")]
			[Space]
			public bool useDithering;

			// Token: 0x04001611 RID: 5649
			[Tooltip("Displays the generated LUT in the top left corner of the GameView.")]
			public bool showDebug;
		}

		// Token: 0x020005BD RID: 1469
		public enum Pass
		{
			// Token: 0x04001613 RID: 5651
			LutGen,
			// Token: 0x04001614 RID: 5652
			AdaptationLog,
			// Token: 0x04001615 RID: 5653
			AdaptationExpBlend,
			// Token: 0x04001616 RID: 5654
			AdaptationExp,
			// Token: 0x04001617 RID: 5655
			TonemappingOff,
			// Token: 0x04001618 RID: 5656
			TonemappingACES,
			// Token: 0x04001619 RID: 5657
			TonemappingCurve,
			// Token: 0x0400161A RID: 5658
			TonemappingHable,
			// Token: 0x0400161B RID: 5659
			TonemappingHejlDawson,
			// Token: 0x0400161C RID: 5660
			TonemappingPhotographic,
			// Token: 0x0400161D RID: 5661
			TonemappingReinhard,
			// Token: 0x0400161E RID: 5662
			TonemappingNeutral,
			// Token: 0x0400161F RID: 5663
			AdaptationDebug
		}
	}
}
